<template>
    <div>
        <am-white-space></am-white-space>
        <yx-select label="供应商" :list="list" v-model="value"></yx-select>
        <am-white-space></am-white-space>
        <am-wing-blank>
            <am-button @click="getValueClicked">获取选中值</am-button>
        </am-wing-blank>
        <am-white-space></am-white-space>
        <am-wing-blank>
            <am-button @click="randomSetValueClicked">随机赋值</am-button>
        </am-wing-blank>
    </div>
</template>

<script>
    import YxSelect from "../../../components/yx-select/index";
    import AmWingBlank from "../../../weex-amui/packages/am-wing-blank/index";
    import AmWhiteSpace from "../../../weex-amui/packages/am-white-space/index";
    import AmButton from "../../../weex-amui/packages/am-button/index";

    import Utils from 'Utils/utils'


    export default {
        name: "select-demo",
        components: {AmButton, AmWhiteSpace, AmWingBlank, YxSelect},
        data(){
            return {
                value:[893],
                list: [
                    {
                        name: '生产厂家',
                        value: 543
                    },
                    {
                        name: '要挟经销商',
                        value: 893
                    },
                    {
                        name: '药械服务商',
                        value: 2019
                    },
                    {
                        name: '配送企业',
                        value: 5738
                    },
                    {
                        name: '代理商',
                        value: 9093
                    }
                ]
            }
        },
        methods: {
            /**
             * 选中值
             */
            getValueClicked (){
              this.$notice.toast({
                  message: JSON.stringify(this.value)
              })
            },
            /**
             * 随机赋值
             */
            randomSetValueClicked (){
                let len = Utils.randomNum(0,this.list.length)
                this.value = []
                for (let i=0;i<len;i++){
                    let ele = this.list[Utils.randomNum(0,this.list.length)]
                    this.value.push(ele.value)
                }

            }
        }
    }
</script>

<style scoped>

</style>
